package clientCommunicationHandler;

import java.util.Vector;

public class Back {
	private Vector<Vector<String>> stack;
	private final String delimiter = (char)1+"";
	
	public Back(){
		this.stack = new Vector<Vector<String>>();
	}
	
	public void removeAll(){
		this.stack.clear();
	}
	public void add(Vector<String> pos){
		this.stack.add(new Vector<String>(pos));
	}
	
	public String refresh(){
		int userDepth = UserInfo.userPosition.size();
		switch(userDepth){
		case(0):
			return "viewForum"+delimiter+UserInfo.userName+delimiter;
		case(1):
			return "viewSubForum"+delimiter+UserInfo.userName+delimiter+this.userLocation();
		case(2):
			return "viewThread"+delimiter+UserInfo.userName+delimiter+this.userLocation();
		}
		return "viewForum"+delimiter+UserInfo.userName+delimiter;
		
	}
	private String userLocation(){
		String loc = "";
		for (String pos : UserInfo.userPosition) {
			loc += pos+delimiter; 
		}
		return loc;
	}
	
	public String back(){
		int pos = UserInfo.userPosition.size()-1;
		String refresh = refresh();
		if(pos >= 0){	
			UserInfo.userPosition.remove(pos);
			refresh = refresh();
		}
		return refresh();
		
	}

}
